<?php
set_time_limit(0);
function my_autoloader($class_name) {
	$type = 'index';
	$dirs = array(
        'Class', 'Class/Model', 'Class/Model/basic', 
        'Configuration', 
        'Class/View', 'Class/View/basic', 'Class/View/type', 
        'Class/Controller', 'Class/Controller/type',
        'Class/DataIn', 'Class/DataOut', 'Class/ChartData',
        'lib', 'lib/PHPExcel'
        
	);
	foreach($dirs as $dir)
	{
            if(file_exists($dir.'/'.$class_name.'.php'))
                require_once "$dir/$class_name.php";
        
			
	}
}

spl_autoload_register('my_autoloader');
Mypdo::connect(ConfigDatabase::host, ConfigDatabase::username, ConfigDatabase::password, ConfigDatabase::dbname);
$models = Network::loadModel();

if(isSet($_GET[ConfigInput::stepGet]) && !empty($_GET[ConfigInput::stepGet])) {
	$controllerName = $_GET[ConfigInput::stepGet];
} else {
	$controllerName = ConfigDefault::MainController;
}
$view = null;
try
{
    $controllerName = ucfirst(strtolower($controllerName)).'Controller';
    $controller = new $controllerName();
    $controller->control();
    $view = $controller->getView();
    $view->display();
}
catch(Error $error)
{ 
   echo 'blad';
}

?>
